import { _decorator, Component, Label } from 'cc';
import { ResourceMgr } from '../../framework/manager/ResourceMgr';
import { l10n } from '../../../../extensions/localization-editor/static/assets/l10n';
const { ccclass, property } = _decorator;

/**
 * 国际化L10n
 */
@ccclass('L10nScene')
export class L10nScene extends Component {

    private resultLabel: Label

    private isSucc: boolean = true;

    protected onLoad(): void {
        this.resultLabel = this.node.getChildByName("Result").getComponent(Label)
        ResourceMgr.Instance.addButtonListen(this.node.getChildByName("Button"), this, this.onToggleResult)
    }

    private onToggleResult() {
        this.isSucc = !this.isSucc
        this.resultLabel.string = this.isSucc ? l10n.t('success') : l10n.t('fail')
    }

}

